/*
 * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <gtest/gtest.h>
#include "ets_interop_js_gtest.h"

namespace panda::ets::interop::js::testing {

class EtsInteropNumberSubtypesTest : public EtsInteropTest {
    void SetUp() override
    {
        interop_js_test_path_ = std::getenv("ARK_ETS_INTEROP_JS_GTEST_SOURCES");
        // This object is used to save global js names
        if (!RunJsScript("var gtest_env = {};\n")) {
            std::abort();
        }
        LoadModuleAs("module", "module.js");
    }
};

% (@integral_primitives + @float_primitives).each do |primitive|
TEST_F(EtsInteropNumberSubtypesTest, TestJSCall<%= primitive.getName() %>)
{
    auto jscall_ret = CallEtsMethod<int64_t>("jscall_<%= primitive.getName() %>");
    ASSERT_EQ(jscall_ret, 0);
}

TEST_F(EtsInteropNumberSubtypesTest, TestJSNewGetProperty<%= primitive.getName() %>)
{
    auto jsnew_ret = CallEtsMethod<int64_t>("jsnew_getproperty<%= primitive.getName() %>");
    ASSERT_EQ(jsnew_ret, 0);
}

TEST_F(EtsInteropNumberSubtypesTest, TestJSNewSetProperty<%= primitive.getName() %>)
{
    auto jsnew_ret = CallEtsMethod<int64_t>("jsnew_setproperty<%= primitive.getName() %>");
    ASSERT_EQ(jsnew_ret, 0);
}

TEST_F(EtsInteropNumberSubtypesTest, TestJSCallStatic<%= primitive.getName() %>)
{
    auto jscall_static_method_ret = CallEtsMethod<int64_t>("jscall_static_method_<%= primitive.getName() %>");
    ASSERT_EQ(jscall_static_method_ret, 0);
}

% end
}  // namespace panda::ets::interop::js::testing
